package ExtendDemo.demo09;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //创建socket对象
        Socket s = new Socket("192.168.0.101", 10002);

        //封装文本文件的数据
        BufferedReader br = new BufferedReader(new FileReader("s.txt"));
        //封装输出流写数据
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));

        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        //自定义结束标记
//        bw.write("886");
//        bw.newLine();
//        bw.flush();

        s.shutdownOutput();
        //接收反馈
        BufferedReader br2 = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String message = br2.readLine();
        System.out.println("服务器的反馈" + message);

        bw.close();
        br.close();
        s.close();

    }
}
